﻿package com.wandian.view.components.ui
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.vo.FaceVo;
	import com.wandian.model.vo.FriendVo;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.PropVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZLlistScrollPanel;
	import com.wandian.util.CLZLoadIcon;
	import com.wandian.util.CLZPanel;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.CLZTxtTip;
	import com.wandian.util.CLZZoom;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.TextControl;
	import com.wandian.util.ToolTip;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;

    public class RedBagPanel extends CLZPanel
    {
        private var _mcPanel:Sprite;
        private var okNotice:String;
        private var closeNotice:String;
        private var _global:GameData;
        private var facade:ApplicationFacade;

        public function RedBagPanel(param1:Sprite, param2:String = "", param3:String = "")
        {
            this._global = GameData.getInstance();
            this.facade = ApplicationFacade.getInstance();
            this.okNotice = param2;
            this.closeNotice = param3;
            this._mcPanel = param1;
            CLZButton.setButton(this._mcPanel["draw_btn"], GameData.tip["DRAW_PRIZE"]);
            this._mcPanel["draw_btn"].addEventListener(MouseEvent.CLICK, this.onDrawHandler);
            TextControl.initTxtTip(this._mcPanel["input_txt"], GameData.tip["ENTER_RED_NUMBER"]);
            this._mcPanel["input_txt"].restrict = "a-z A-Z 0-9";
            if (this._global.userInfo.userVo.gp != GameData.QZONE_SID)
            {
            }
            if (this._global.userInfo.userVo.gp == GameData.FRIEND_SID)
            {
                this._mcPanel["tip_txt"].text = GameData.tip["RED_BAG_TIP_Q"];
            }
            else
            {
                this._mcPanel["tip_txt"].text = GameData.tip["RED_BAG_TIP"];
            }
            this._mcPanel["title_txt"].text = GameData.tip["RED_BAG_NAME"];
            this._mcPanel["numName_txt"].text = GameData.tip["CARD_NUM"] + "：";
            if (this._global.userInfo.userVo.gp != GameData.QZONE_SID)
            {
            }
            if (this._global.userInfo.userVo.gp == GameData.FRIEND_SID)
            {
                if (this._global.userInfo.userVo.isaddf)
                {
                    CLZButton.setButton(this._mcPanel["ok_btn"], GameData.tip["WEI_BO_ON"]);
                }
                else
                {
                    CLZButton.setButton(this._mcPanel["ok_btn"], GameData.tip["WEI_BO_LISTER"]);
                }
                this._mcPanel["ok_btn"].visible = true;
            }
            else
            {
                this._mcPanel["ok_btn"].visible = false;
            }
            super(param1, this.onOK, this.onClose);
            return;
        }

        private function onDrawHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this._mcPanel["input_txt"].text;
            if (_loc_2 == GameData.tip["ENTER_RED_NUMBER"])
            {
                CLZTxtTip.addTip(this._mcPanel["input_txt"], GameData.tip["ENTER_RED_NUMBER"]);
                return;
            }
            CLZTxtTip.removeTip(this._mcPanel["input_txt"]);
            this.facade.sendNotification(CLZNoticeName.RED_REQ, _loc_2);
            this.onClose();
            return;
        }

        public function onClose() : void
        {
            if (this.closeNotice == "")
            {
                this.facade.sendNotification(this.okNotice);
            }
            else
            {
                this.facade.sendNotification(this.closeNotice);
            }
            super.remove();
            return;
        }

        public function onOK() : void
        {
            if (this._global.userInfo.userVo.isaddf)
            {
//                JSFUN.onWeiBoFunc();
            }
            else
            {
                this.facade.sendNotification(this.okNotice);
            }
            super.remove();
            return;
        }

    }
}
